import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//屏幕适配工具类
class CustomScreenUtil {
  //初始化屏幕适配
  static init(context) {
    ScreenUtil.init(
        BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width,
            maxHeight: MediaQuery.of(context).size.height),
        designSize: Size(375, 812),
        orientation: Orientation.portrait);
  }

  //设置高度
  static setHeight(double height) {
    return ScreenUtil().setHeight(height);
  }

  //设置宽度
  static setWidth(double width) {
    return ScreenUtil().setWidth(width);
  }

  //设置字体 allowFontScalingSelf是false不跟随系统改变字体大小
  static setFontSize(double fontSize) {
    return ScreenUtil().setSp(fontSize);
  }

  ///获取当前设备宽度
  static getCurrentScreenWidthDp() {
    return ScreenUtil().screenWidth;
  }

  ///获取当前设备高度
  static getCurrentScreenHeightDp() {
    return ScreenUtil().screenHeight;
  }
}
